package two;

/**
 * Created with IntelliJ IDEA.
 * ClassName: ArrayTwo
 * Package: two
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-08-15
 * Time: 17:35
 */

//二维数组
public class ArrayTwo {
    public static void main(String[] args) {

        //数组声明和初始化 静态初始化 编译时期就确定了
        int[][] arr1 = new int[][]{{1,2,3},{4,5,6}};

        //动态初始化 三行四列
        int[][] arr2 = new int[3][4];

        //可以省略列
        double[][] arr4 = new double[2][];

        ///数组元素调用 看成内存元素 和 外层元素 {1,2,3},{4,5,6}
        System.out.println(arr1[0][0]);

        //调用外层元素 [I@1b6d3586 指向的内层
        System.out.println(arr1[0]);

        //数组的长度
        System.out.println(arr1.length); //2
        System.out.println(arr1[0].length);

        System.out.println("遍历");
        //数组遍历
        for (int i = 0; i < arr1.length; i++) {
            for (int j = 0; j <arr1[i].length; j++) {
                System.out.print(arr1[i][j] + " ");
            }
            System.out.println();
        }

    }
}
